package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsStreamShop;
import com.scau402.system.service.IWmsStreamShopService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 直播店铺Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/streamShop")
public class WmsStreamShopController extends BaseController
{
    @Autowired
    private IWmsStreamShopService wmsStreamShopService;

    /**
     * 查询直播店铺列表
     */
    @PreAuthorize("@ss.hasPermi('system:streamShop:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsStreamShop wmsStreamShop)
    {
        startPage();
        List<WmsStreamShop> list = wmsStreamShopService.selectWmsStreamShopList(wmsStreamShop);
        return getDataTable(list);
    }

    /**
     * 导出直播店铺列表
     */
    @PreAuthorize("@ss.hasPermi('system:streamShop:export')")
    @Log(title = "直播店铺", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsStreamShop wmsStreamShop)
    {
        List<WmsStreamShop> list = wmsStreamShopService.selectWmsStreamShopList(wmsStreamShop);
        ExcelUtil<WmsStreamShop> util = new ExcelUtil<WmsStreamShop>(WmsStreamShop.class);
        util.exportExcel(response, list, "直播店铺数据");
    }

    /**
     * 获取直播店铺详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:streamShop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsStreamShopService.selectWmsStreamShopById(id));
    }

    /**
     * 新增直播店铺
     */
    @PreAuthorize("@ss.hasPermi('system:streamShop:add')")
    @Log(title = "直播店铺", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsStreamShop wmsStreamShop)
    {
        wmsStreamShop.setCreateBy(getUsername());
        return toAjax(wmsStreamShopService.insertWmsStreamShop(wmsStreamShop));
    }

    /**
     * 修改直播店铺
     */
    @PreAuthorize("@ss.hasPermi('system:streamShop:edit')")
    @Log(title = "直播店铺", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsStreamShop wmsStreamShop)
    {
        return toAjax(wmsStreamShopService.updateWmsStreamShop(wmsStreamShop));
    }

    /**
     * 删除直播店铺
     */
    @PreAuthorize("@ss.hasPermi('system:streamShop:remove')")
    @Log(title = "直播店铺", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsStreamShopService.deleteWmsStreamShopByIds(ids));
    }

    /**
     * 启用、停用店铺
     * @param wmsStreamShopList
     * @return
     */
    @Log(title = "店铺资料", businessType = BusinessType.UPDATE)
    @PostMapping("/startOrStop")
    public AjaxResult startOrStop(@RequestBody List<WmsStreamShop> wmsStreamShopList){
        return toAjax(wmsStreamShopService.startOrStop(wmsStreamShopList));
    }
}
